﻿<%@ WebHandler Language="C#" Class="SIPO.Web.AjaxHandler.Loaddata.gettransactiontype" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;
using SIPO.Library.Enum;
using SIPO.Web.Support;
using Newtonsoft.Json.Linq;
namespace SIPO.Web.AjaxHandler.Loaddata
{
    public class gettransactiontype : SIPO.Web.BaseHandler
    {
        recTransactionTypeRepo recTransactionTypeDal = new recTransactionTypeRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
        string MethodName = string.Empty;
        string InvoiceNo = string.Empty;
        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);

            if (context.Request.Params["method"] != null)
                MethodName = context.Request.Params["method"];

            if (MethodName == "getjenisinvoice")
            {
                if (context.Request.Params["invoiceno"] != null)
                    InvoiceNo = context.Request.Params["invoiceno"];
                
                List<recTransactionType> list = recTransactionTypeDal.GetListByInvoiceNoReport(InvoiceNo);
                var result = list;
                context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));
            
            }else if (MethodName == "gettranstype")
                {
                    List<recTransactionType> list = recTransactionTypeDal.GetList();
                    var result = list;

                    context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));
                }
            else
            {

                short id = Convert.ToInt16(context.Request.Params["transtype_id"]);
                List<recTransactionType> list = recTransactionTypeDal.GetList();
                var result = list.Where(x => x.TransTypeID == id);

                context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));
            }
        }

        public override bool IsReusable
        {
            get
            {
                return false;
            }
        }

    }
}